package com.atguigu.flink.datastramapi.source;

import com.atguigu.flink.function.MySourceFunction;
import org.apache.flink.streaming.api.environment.StreamExecutionEnvironment;

/**
 * Created by Smexy on 2023/2/24
 *
 *  自定义source。
 *      常见的Source官方都已经提供，不需要自定义。
 *      只适用于模拟数据。
 *
 *      env.addSource(SourceFunction x): 负责添加数据源。
 */
public class Demo4_CustomSource
{
    public static void main(String[] args) {

        StreamExecutionEnvironment env = StreamExecutionEnvironment.getExecutionEnvironment();

        //env.setParallelism(1);

        env.addSource(new MySourceFunction()).setParallelism(10)
            .print();


        try {
            env.execute();
        } catch (Exception e) {
            e.printStackTrace();
        }


    }
}
